<template>

        <div >
            <div class="signIn">
                <div>
                    <van-nav-bar title="签到" left-arrow   @click-left="$router.go(-1)" />
                </div>
                <div class="header_placeholder" style="width:100%;height:4rem" id="cust_head"></div>
            </div>
            <div class="signIn_main">
                <div class="signIn_top">
                    <div class="signIn_top_info">
                        <p><span>资产：</span>{{data.assets}} AZC</p>
                        <p><span>余额：</span>{{data.surplus}}</p>
                        <p><span>AZC：</span>{{data.AZC}}</p>
                        <p><span>USDT：</span>{{data.USDT}}</p>
                    </div>
                    <div :class="[data.status==1?'signIn_center checkedIn':'signIn_center']" @click='signInFun'>
                        <h1 v-if="data.status==1">已签到</h1>
                        <h1 v-if="data.status==0">签到</h1>
                        <p>已连续签到{{data.number}}天</p>
                    </div>
                </div>
                <div class="signIn_week">
                    <p>每日签到可获得千分之二矿池释放奖励！</p>
                    <!-- <span>连续签到7天即可领取奖励哦，加油！</span> -->
                    <ul>
                        <li v-for='(week,index) in weeks' >
                            <p :class="[ sign_in==false||(index+1)==data.week_status||(data.week[0]==1&&index==0)||(data.week.length!=1&&data.week[index]==index)  ?'weekCheckedIn':'']"><van-icon name="success" /></p>
                            <span>{{week}}</span>
                        </li>
                    </ul>
                </div>
                <div class="signIn_rule">
                    <h5 v-html="rule.cate_name"></h5>
                    <p  v-html="rule.content"></p>
                </div>
            </div>
        </div>
</template>

<script>


export default {
 name: "login",
data() {
    return {
                    weeks:["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
                    isWeekSign: false,
                    weekIdx:-1,
                    data:{week:[]},
                    rule:{},
                    sign_in:false
    }
},
mounted() { 
    this.base.head_status(1)
    this.getRegister_metd();
    this.GetRang_metd(1);
},
 methods: {
               
       getRegister_metd(){
                 let that=this;
            
                    var data={token:JSON.parse(localStorage.userinfo).token}
                        that._API.getRegister(data).then(res => {
                            if(res.code==200){
                               that.data=res.data;
                               if(that.data.week.length){
                                   if(that.data.week[0]==0){
                                       that.sign_in=true;
                                   }
                               }
                             
                                 
                            }else{
                                 that.$dialog.alert({title: '提示信息', message: res.msg }).then(() => {
                                   
                                    });
                                 
                            }
                           
                            
                            }).catch(err => {
                                console.log("err", err);
                            });
     },
         GetRang_metd(num){

             let that=this;
        
             var data={token:JSON.parse(localStorage.userinfo).token,id:num}
                       that._API.article(data).then(res => {
                            if(res.code==200){
                                that.rule=res.data;
                                 
                            }else{
                                 that.$toast({ message: res.msg, position: "bottom" });
                            }
                           
                        }).catch(err => {
                            console.log("err", err);
                        });
     },
     signInFun(){

                    let that=this;

                    if(that.data.status==1){
                         that.$toast({ message: "今天你已经签到过了", position: "bottom" });
                        return
                    }
                     var data={token:JSON.parse(localStorage.userinfo).token}
                        that._API.register_roll(data).then(res => {
                            if(res.code==200){
                                  that.$toast({ message: res.msg, position: "bottom" });
                                that.getRegister_metd();
                                 
                            }else{
                                 that.$dialog.alert({title: '提示信息', message: res.msg }).then(() => {
                                   
                                    });
                                 
                            }
                           
                            
                            }).catch(err => {
                                console.log("err", err);
                            });
     },
               


      }
}
</script>


<style lang="scss" scoped >
   .van-nav-bar{
                background: #1C003F;
                width:100%;
                position: fixed;
            }
            .van-nav-bar .van-icon{
                color:#fff;
            }
            .van-nav-bar__arrow{
                font-size:20px;
            }
            .van-nav-bar__title{
                color:#fff;
            }
            .signIn_main{
                padding:0 0rem;
                width:100%;
                box-sizing: border-box;
            }
            .signIn_top{
                width:100%;
                height: 20rem;
                background: url('../../assets/img/mine/signIn_bg.png') no-repeat center/100%;
                position: relative;
            }
            .signIn_top_info{
                padding:1rem 0 0 1rem;
                color:#00C6FF;
                font-size: 0.9rem;
            }
            .signIn_top_info span{
                width:3rem;
            }
            .signIn_center{
                position:absolute;
                top:5rem;
                left:0;
                right:0;
                margin: 0 auto;
                width:8.25rem;
                height:8.25rem;
                background:radial-gradient(circle,#BB05FF,#8912EF);
                border-radius: 50%;
                text-align: center;
            }
            .checkedIn{
                background:none;
            }
            .signIn_center h1{
                font-size:2rem;
                background: linear-gradient(#fff, #1682FF);
                -webkit-background-clip: text;
                color: transparent;
                margin-top:2rem;
            }
            .signIn_center p{
                font-size: 0.86rem;
            }
            .signIn_week{
                box-shadow: 0 0 0.2rem 0.1rem #8921ff inset;
                width:100%;
                border-radius: 0.3rem;
                padding:0.5rem 0.4rem; 
                margin-top:.5rem;
                box-sizing: border-box; 
            }
            .signIn_week>p{
                font-size:0.9rem;
                margin:1rem 0;
            }
            .signIn_week>p em{
                font-size:1rem;
                font-weight: 600;
            }
            .signIn_week>span{
                font-size:0.84rem;
                color: rgba(255,255,255,0.6);
            }
            .signIn_week ul{
                margin-top:0.7rem;
                display: flex;
            }
            .signIn_week ul li{
                flex: 1;
                text-align: center;
            }
            .signIn_week ul li p{
                width:1.5rem;
                height:1.5rem;
                background:rgba(255,255,255,0.5);
                border-radius: 50%;
                margin:0.1rem auto;
            }
            .signIn_week ul li .weekCheckedIn{
                background:#8912EF;
            }
            .van-icon{
                font-size:1.2rem;
                line-height: 1.5rem;
                color: #1C003F;
            }
            .signIn_week ul li span{
                margin-bottom:0.4rem;
                font-size: 0.82rem;
            }
            .signIn_rule{
                padding:0 0.4rem;
            }
            .signIn_rule h5{
                font-size: 0.9rem;
                font-weight: 400;
                margin-top:0.8rem;
                line-height: 1rem;
            }
            .signIn_rule p{
                font-size:0.84rem;
                color:rgba(255,255,255,0.6);
                line-height:1.8rem;
            }
</style>
